<template>
  <div class="jingxuan" >
    <van-tabs :active="active" :sticky='true' @change="k" :scroll-top="scrollTop">
      <van-tab :title="item.name" v-for="(item,index) in category" :key="index">
        <ul class="guessList">
        <li v-for="(item1,index1) in list" :key="index1">
          <a :href="'/pages/detail/main?type=1&join_id=0&limit_id=0&group_id=0&goods_id='+item1.goods_id">
            <div class="img">
              <img :src="item1.image" alt="">
            </div>
            <p class="guessListName">
              {{item1.goods_name}}
            </p>
            <p class="guessListPrice">
              <span>￥<span style="font-size: 17px">{{item1.sell_price}}</span></span>
              <span style="color:#F3891B;float:right;vertical-align:middle">
                 <img src="/static/img/fire.png" alt="" style="width:12px;height:12px;vertical-align:middle;margin-right: 3px">
                <span style="vertical-align:middle">{{item1.popularity}}</span>
              </span>
            </p>
          </a>
        </li>
      </ul>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import request from '@/actions/request.js'
export default {
  data () {
    return {
        category_id:'',
        page:1,
        data:{
          all_page:0,
        },
        active:0,
        scrollTop:0,
        list:[]
    }
  },
  onPageScroll(event) {
    this.scrollTop=event.scrollTop
  },
  props:['categoryId','category'],
  components: {
  },
  methods: {
    onChange (e) {
      let index=e.mp.detail.index;
      this.page=1;
      this.list=[];
      this.category_id=this.category[index].category_id;
      this.getDataEmpty();
      this.getGoodsList();
    },
    pageAdd(){
      if(this.page<this.data.all_page){
        this.page++;
        this.getGoodsList();
      }else{

      }
    },
    getGoodsList() {
      request.getGoodsByCid('api/Shop/getGoodsByCid', 'post', {category_id:this.category_id,page:this.page}, {}, false,this);
    },
    getDataEmpty() {
      this.list=[];
    }
  },

  created () {

  },
  onShow (){

  },
  mounted () {
    this.category_id=this.categoryId;
    this.getGoodsList()
  }
}
</script>

<style scoped lang="scss">
.jingxuan{
  min-height: 100vh;
}
  .guessListName{
    overflow:hidden;
    line-height: 20px;
    text-overflow:ellipsis;
    display:-webkit-box;
    -webkit-box-orient:vertical;
    -webkit-line-clamp:2;
    -moz-box-orient:vertical;
    -moz-line-clamp:2;
    height: 3em;
    margin: 1em;
    font-size: 13px;
    color: #333333;
    margin-bottom: 0px;
}
.guessListPrice{
    margin:0 12px;
    line-height: 40px;
    span{
        color:#FF4C50;
        font-size: 12px;
    }
}
.guessList{
    display:flex;
    justify-content: space-between;
    width: 92vw;
    margin: 0 auto;
    margin-top: 20px;
    flex-wrap: wrap;
    li{
        width:44vw;
        border-radius: 8px;
        overflow: hidden;
        background :#f5f5f5;
        margin-bottom: 15px;
        .img{
          height: 44vw;
          vertical-align: middle;
          line-height: 44vw;
          overflow: hidden;
          background: #ffffff;
        }
        img{
          width: 100%;
          height: 100%;
          vertical-align: middle;
        }
    }
}
</style>
